<template>
	<el-container>
		<el-main class="nopadding">
			<scTable ref="table" :apiObj="apiObj" row-key="runId" stripe remoteSort remoteFilter>
				<el-table-column label="#" type="index" width="50"></el-table-column>
				<el-table-column label="流水号" prop="id" width="150"></el-table-column>
				<el-table-column label="报销事由" prop="subjectMatter" width="150"></el-table-column>
				<el-table-column label="费用汇总" prop="costAggregation" width="150" ></el-table-column>



				<el-table-column label="申请人" prop="userName" width="150"></el-table-column>
				<el-table-column label="申请人部门" prop="userDeptName" width="150"></el-table-column>
				<el-table-column label="审批人" prop="approverNames" width="150"></el-table-column>
				<el-table-column label="审批人部门" prop="approverDeptNames" width="150"></el-table-column>
				<el-table-column label="状态" prop="status">
					<template #default="scope">
						<span v-if="scope.row.status === '0'">审核中</span>
						<span v-else-if="scope.row.status === '1'">通过</span>
						<span v-else-if="scope.row.status === '2'">驳回</span>
						<span v-else-if="scope.row.status === '3'">初始化</span>
						<span v-else-if="scope.row.status === '99'">撤销</span>
					</template>
				</el-table-column>
				 <el-table-column label="操作" fixed="right" align="right" width="100">
					<template #default="scope">
						<el-button-group>
							<el-button text type="primary" size="small" @click="readBpmDetails(scope.row,scope.$index)">查看费用报销明细</el-button>
						</el-button-group>
					</template>
				</el-table-column>
			</scTable>
			<el-dialog v-model="dialogVisible" title="费用明细" width="60%">
				<el-table :data="oaFinanceDetails">
					<el-table-column label="id" prop="id" ></el-table-column>
					<el-table-column label="内容" prop="content" ></el-table-column>
					<el-table-column label="金额" prop="amount" ></el-table-column>
				</el-table>
				<template #footer>
					<el-button @click="dialogVisible = false">关闭</el-button>
				</template>
			</el-dialog>

		</el-main>
	</el-container>
</template>

<script>
import scSelectFilter from '@/components/scSelectFilter'

export default {
	name: 'My Attend Record',
	components: {
		scSelectFilter,
	},
	data() {
		return {
			dialogVisible: false, // 控制弹窗显示
			oaFinanceDetails: [], // 存储费用报销明细数据
			dialog: {
				save: false,
				detailsSave: false
			},

			apiObj: null,
			search: {
				attendType:'',
				date: '',
				// page: 1,
				// pageSize: 15
			}
		}
	},
	mounted() {
		this.initApiObj(); // 初始化时调用
	},
	methods: {
		// 初始化apiObj
		initApiObj() {
			const userInfo = this.$TOOL.data.get("USER_INFO");
			this.apiObj = {
				get: async (params) => {
					// 合并固定参数（userInfo.id）和动态参数（this.search）
					const mergedParams = {
						option1: userInfo.id,
						...this.search,
						...params // 允许外部传入的params覆盖默认值
					};
					return await this.$API.office.personalFinance.getByApplicant.get(mergedParams);
				}
			};
			console.log("this.apiObj费用报销", this.apiObj)
		},
		// 筛选条件变化时更新参数并刷新表格
		filterChange(data) {
			this.search.date = data.date;
			this.search.attendType = data.attendType;
			this.$refs.table.upData(this.search); // 触发表格重新加载
		},
		readBpmDetails(row,index){
			this.oaFinanceDetails = row.oaReimbursementDetails;
			this.dialogVisible = true; // 显示弹窗
		},

	}
}
</script>

<style>
</style>
